/**
 *--------------------------------------------------------------------\n
 *          HSLU T&A Hochschule Luzern Technik+Architektur            \n
 *--------------------------------------------------------------------\n
 *
 * \brief         Global definitions for the whole project.
 * \file
 * \author        Christian Jost, christian.jost@hslu.ch
 * \date          19.08.2011
 *
 * \b Language:   Ansi-C \n\n
 * \b Target:     Medusa-Trainer \n
 *
 *
 * $Id: platform.h 7 2011-08-22 07:56:12Z zajost $
 *--------------------------------------------------------------------
 */
#ifndef PLATFORM_H
#define PLATFORM_H

/* Include the derivative-specific header file */
#include <mc9s08gb60a.h>

#define _Stop asm ( stop; )
  /*!< Macro to enter stop modes, STOPE bit in SOPT1 register must be set prior to executing this macro */

#define _Wait asm ( wait; )
  /*!< Macro to enter wait mode */



// ext. crystal = 9.8304MHz => fBus = 4.9152MHz
#define ICGC1_VALUE         0xF0        //!< ICG-Mode: FBE (FLL bypassed, external reference) for high freq. crystal
#define ICGC2_VALUE         0x00        //!< F = 9.8304MHz / R=1 = 9.8304MHz => fBus = 4.9152MHz
#define BUSCLOCK            4915200     //!< Frequency of the bus [Hz]                            


/*
// Other configuration options:
// ext. crystal with 9.8304MHz => fBus = 4.9152MHz (old medusa configuration)
#define ICGC1_VALUE         0x78        //!< ICG-Mode: FEE (FLL engaged, ext. reference) for high freq. crystal
#define ICGC2_VALUE         0x02        //!< F = 9.8304MHz x N=4 / R=4 = 9.8304MHz => fBus = 4.9152MHz
#define BUSCLOCK            4915200     //!< Frequency of the bus [Hz]

// ext. crystal with 32.768kHz => fBus = 4.718592MHz
#define ICGC1_VALUE         0x38;       //!< ICG-Mode: FEE (FLL engaged, ext. reference) for low freq. crystal           
#define ICGC2_VALUE         0x72;       //!< F = 32.768kHz x 64 x N=18 / R=4 = 9.437184MHz => fBus = 4.718592MHz
#define BUSCLOCK            4718592     //!< Frequency of the bus [Hz]
   
// no crystal, only int. reference => fBus = 4.9989MHz
#define ICGC1_VALUE         0x28;       //!< ICG-Mode: FEI (FLL engaged, internal reference)
#define ICGC2_VALUE         0x72;       //!< F = (243kHz / 7) x 64 x N=18 / R=4  = 9.9977MHz => fBus 4.9989MHz
#define BUSCLOCK            4998900     //!< Frequency of the bus [Hz]
*/



typedef struct {
    unsigned int  stackFree;                    /* Number of free bytes on the stack                            */
    unsigned int  stackUsed;                    /* Number of bytes used on the stack                            */
} tStackData;


void ClearStack(void);


#endif
